package football.haha.com.footballtv.fragment;

import android.support.v4.app.Fragment;
import android.view.View;
import android.view.ViewGroup;
import football.haha.com.footballtv.R;
import football.haha.com.footballtv.view.FocusBorderView;

/**
 * Created by haha on 2017/10/4.
 */

public class BaseFragment extends Fragment implements View.OnFocusChangeListener{

    public FocusBorderView borderView;
    public float scale = 1.15f;

    /**
     * @param rootView 创建边框View
     */
    public void createBorderView(ViewGroup rootView) {
        borderView = new FocusBorderView(getActivity());
        borderView.setBorderBitmapResId(R.drawable.bg_shape_white);
        borderView.setBorderViewHide();

        if (rootView != null) {
            rootView.addView(borderView);
        }
    }

    @Override
    public void onFocusChange(View v, boolean hasFocus) {
        if (hasFocus) {
            v.bringToFront();
            v.getParent().bringChildToFront(v);
            v.requestLayout();
            v.invalidate();
            borderView.bringToFront();
            borderView.setHideView(false);//这一句非常重要
            borderView.setFocusView(v, scale);
        } else {
            borderView.setUnFocusView(v);
            borderView.setHideView(true);
        }

    }

}
